import { get, post } from "utils/fetch";
// import { post } from 'utils/fetch';

// 流程详情, modelCode兼容其他系统
export const getModelDetail = ({ modelId, modelCode }) => {
  return post(`/flow-platform/model/detail`, { modelId, modelCode });
};
// 流程详情已部署
export const getDeploymentDetail = ({ deploymentId }) => {
  return post(`/flow-platform/model/deployment/detail`, { deploymentId });
};
// 流程模型保存
export const saveModel = (data) => {
  return post(`/flow-platform/model/save`, data, { messageType: "close" });
};
// 流程任务事件通知
export const testConnection = (data) => {
  return get(`/flow-platform/model/task/testConnection`, data, { messageType: "close" });
};

// 流程模型保存
export const getCandidateGroups = (data) => {
  // return get(`/flow-platform/model/candidateGroups`, {}, { messageType: 'close' });
  // return post(`/flow-platform/model/candidateGroups`, data, { messageType: "close" });
  return post(`/flow-platform/4A/getAllUserGroupList`, data, { messageType: "close" });
};

// 获取通知渠道
export const getNoticeChannelType = () =>
  get("/flow-platform/notice/channel/getNoticeChannelType");

// 根据模板类型查询模板
export const getTemplateListByType = (data) =>
  get(`/flow-platform/notice/template/getTemplateListByType`, data);

// 通知模板参数列表查询
export const getTemplateParameter = (data) =>
  get(`/flow-platform/notice/template/listNoticeTemplateParameter`, data);

/*
export const getNoticeChannelType = () => Promise.resolve({
  errCode: 0,
  datas: [
    { name: "系统通知", code: "SYSTEM" },
    { name: "钉钉", code: "DINGDING" },
    { name: "短信", code: "MSG" },
    { name: "邮件", code: "MAIL" },
  ],
})
*/
// 用户组
export const getUserGroupList = (data) => {
  return post(`/flow-platform/api/v1.0/public/getUserGroupList`, data, { messageType: "close" });
};

// 岗位
export const getAllPositionList = (data) => {
  return post(`/flow-platform/api/v1.0/public/getAllPositionList`, data, { messageType: "close" });
};

// 关系
export const getUserRelationShipList = (data) => {
  return post(`/flow-platform/api/v1.0/public/getUserRelationShipList`, data, { messageType: "close" });
};

// 自定义函数
export const getAllFunctionConfigList = (data) =>
  get(`/flow-platform/4A/getAllFunctionConfigList`, data);

// 配置流程，添加事件的时候前端调用接口检查事件url合法性
export const checkFlowChartUrl = (data) => {
  return post(`/flow-platform/model/CheckUrl`, data)
}

// 配置流程，添加事件的时候前端调用接口检查事件url合法性
export const testEvent = (data) => {
  return post(`/flow-platform/model/testEvent`, data)
}

// 补发
export const supplySignTask = (data) => {
  return post(`/flow-platform/supply/supplySignTask`, data)
}

// 文档删除
export const deleteFile = (data) =>
  get(`/flow-platform/oss/deleteFile`, data);


// 角色分页查询
export const getUserRolePageList = (data) => {
  return post(`/flow-platform/api/v1.0/public/getUserRolePageList`, data)
}

// 组织分页查询
export const getUserGroupPageList = (data) => {
  return post(`/flow-platform/api/v1.0/public/getUserGroupPageList`, data)
}

// 岗位分页查询
export const getUserPositionPageList = (data) => {
  return post(`/flow-platform/api/v1.0/public/getUserPositionPageList`, data)
}

// 新增自定义函数
export const saveFunctionConfig = (data) => {
  return post(`/flow-platform/api/v1.0/public/saveFunctionConfig`, data, { messageType: "close" });
};

// 删除自定义函数
export const deleteFunctionConfig = (data) => {
  return post(`/flow-platform/api/v1.0/public/deleteFunctionConfig`, data, { messageType: "close" });
};
